package cn.lifei.auth.controller;

import cn.lifei.auth.dto.LoginDTO;
import cn.lifei.auth.service.ILoginService;
import cn.lifei.auth.vo.LoginVO;
import cn.lifei.basic.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private ILoginService loginServiceImpl;

    @PostMapping
    public AjaxResult login(@RequestBody LoginDTO loginDTO){
        try {
            LoginVO loginVO=loginServiceImpl.login(loginDTO);
            return AjaxResult.success(loginVO);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error("登录失败！"+e.getMessage());
        }
    }
    @PutMapping
    public AjaxResult loginOut(){
        try {
            return AjaxResult.success();
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error("登录失败！"+e.getMessage());
        }
    }

}
